*---------------------------------------------------------------
*---------------------------------------------------------------
* This code base replicates sampling diagnoistics reported in 
* Figure A4, panels a, b, c
*---------------------------------------------------------------
*---------------------------------------------------------------

clear all

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
* To manually run file, set the working directory below *
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

cd "~/Dropbox/Historical Displacement and Ethnicity - Afghanistan/REPOSITORY"

*---------------------------------------------------------------
* Section 1: Load and define variables in ANQAR sampling diagnoistics 
*---------------------------------------------------------------

use "replication/data/input/ANQAR_sampling.dta", clear

* wave = wave of ANQAR sample collection conducted by ACSOR
* cooperation_rate = I / (I + R)
* refusal_rate = R / (I + R + NC + O + UH)
* noncontact_rate = NC / (I + NC)

*---------------------------------------------------------------
* Section 2: Make Figure A4a
*---------------------------------------------------------------

scatter refusal_rate wave, msymbol(O) mcolor(navy) yscale(range(0 .06)) ylabel(0 (.01) .06) text(0.042 15.4 "SD+") text(.032 15.4 "SD-") yline(.037016, lc(gray)) yline(0.0437564, lc(gray) lpattern(dash)) yline(0.0302756, lc(gray) lpattern(dash))  xtitle("ANQAR Survey Wave (Quarterly)") ytitle("Refusal Rate") title("Respondent Refusal to Take Survey Among Targets") graphregion(color(white))

graph export "replication/results/figures/FigureA4a.pdf", replace

*---------------------------------------------------------------
* Section 3: Make Figure A4b
*---------------------------------------------------------------

scatter noncontact_rate wave, msymbol(O) mcolor(navy) yscale(range(0 .06)) ylabel(.01 (.01) .05) text(.033 15.4 "SD+") text(.027 15.4 "SD-") yline(.0296254, lc(gray)) yline(0.0346725, lc(gray) lpattern(dash)) yline(0.0245783, lc(gray) lpattern(dash))  xtitle("ANQAR Survey Wave (Quarterly)") ytitle("Non-Contact Rate") title("Contact with Targeted Respondent not Possible") graphregion(color(white))

graph export "replication/results/figures/FigureA4b.pdf", replace

*---------------------------------------------------------------
* Section 4: Make Figure A4c
*---------------------------------------------------------------

scatter cooperation_rate wave, msymbol(O) mcolor(navy) yscale(range(.9 1)) ylabel(.9 (.02) 1)  text(.963 15.4 "SD+") text(.954 15.4 "SD-") yline(.9583119, lc(gray)) yline(0.9659886, lc(gray) lpattern(dash)) yline(0.9506352, lc(gray) lpattern(dash))  xtitle("ANQAR Survey Wave (Quarterly)") ytitle("Cooperation Rate") title("Respondent Cooperation with Survey Enumerators") graphregion(color(white))

graph export "replication/results/figures/FigureA4c.pdf", replace
